<?php

//include('Collection.php');
$RapMusic = new RapMusic();

$RapMusic->load();


class Collection{
	private $_members=array(); //container for our objects
	public $Logger;
	
	public function addItem($obj,$key){
		if($key){
			echo($key);
			if(isset($this->_members[$key])){
				print_r($this->_members);
				throw new Exception($this->_members);
			}else{
				$this->_member[$key]=$obj;
			}
		}else{
			$this->_member[]=$obj;
		}
	}

	public function getItem($key){
		if(isset($this->_members[$key])){
			return $this->_members[$key];
		}else{
			throw new Exception("Sorry but the existing Key Doesn't not exist keys::".$this->_members);
		}
	}

	public  function removeItem($key){
		if(isset($this->_members[$key])){
			unset($this->_members[$key]);
		}else{
			throw new Exception("Sorry but the existing Key Doesn't not exist keys::".$this->_members);
		}
	}

	public function length(){
		return sizeof($this->_members);
	}

}


class RapMusic {
	private $albumname;
	private $year_release;
	
	public function __construct($name ="",$year_release ="")
	{
		$this->albumname=$name;
		$this->year_release=$year_release;
	}
	
	public  function __toString() // this function prints the following upon attempt to print an Object
	{
		return "Album Name:".$this->albumname." Artist Release Date:".$this->year_release;
	}
	
	public function load(){
		$RapDJMixVol1 = new Collection();
		$RapDJMixVol1->addItem(new RapMusic("Recovery-Eminem",2002),"Eminem");
		$RapDJMixVol1->addItem(new RapMusic("M.I",2002),"Mr Incredible");
		$RapDJMixVol1->addItem(new RapMusic("Slim.T",2002),"Die Representing");
		
		print $RapDJMixVol1->getItem("Eminem"); //this will display Album Name:Recovery-Eminem    Artist Release Date:2002

	}
}
?>